-- Copyright (c) 2025 Huawei Technologies Co., Ltd.
-- openUBMC is licensed under Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at:
--         http://license.coscl.org.cn/MulanPSL2
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
-- EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
-- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
-- See the Mulan PSL v2 for more details.

local log = require 'mc.logging'
local handler_channel = require 'debug.can_channel'
local remote_access = require 'debug.remote_access'

local handler_collection = {}

handler_collection.cmds = {
        CHANNEL_BOARDCAST = 1,
        CHANNEL_METRICS = 2,
        REMOTE_PROPERTIES = 3,
        REMOTE_METHOD = 4
}

local handler_maps = {
    [handler_collection.cmds.CHANNEL_BOARDCAST] = handler_channel.send_boardcast,
    [handler_collection.cmds.CHANNEL_METRICS] = handler_channel.print_metrics,
    [handler_collection.cmds.REMOTE_PROPERTIES] = remote_access.get_remote_properties,
    [handler_collection.cmds.REMOTE_METHOD] = remote_access.call_remote_method
}

function handler_collection.get_handler(command)
    if not handler_maps[command] then
        log:error('invalid debug command [%s]', command)
        return {}
    end
    return handler_maps[command]
end

return handler_collection